import cv2
img = cv2.imread("../images/lena.png")
print(img.shape)
cv2.imshow("orginal image",img)
cv2.waitKey(0)
roi = cv2.selectROI("select roi",img)
print(roi)
x,y,w,h = roi
roi_img = img[y:y+h,x:x+w]
cv2.imshow("selectROI img", roi_img)
cv2.waitKey(0)

if cv2.imwrite("zhangsan.png",roi_img):
    print("成功保存")
else:
    print("保存失败")

